Initial commit
[RGBW Controller] / make
1 #!/bin/bash 
2
3 if [ $# -lt 1 ]; then
4         echo "Usage: $0 <sketch name> [upload]"
5         exit 0
6 fi 
7
8 # assign WIFI_SSID and WIFI_PASS in external file ../info
9 # source "../info"
10
11 SKETCH="$1/$1.ino"
12
13 TMP="/tmp/ESPcompile.tmp"
14
15 MAKE_FILE="~/Bin/SDK/ESP/makeEspArduino/makeEspArduino.mk"
16 ESP_SDK_ROOT=~/Bin/SDK/arduino-1.8.5/hardware/esp8266com/esp8266        # keep it without quotation marks
17
18 # nodemcuv2, generic, esp8285
19 # F_CPU=80000000L 
20 # BUILD_EXTRA_FLAGS="-DIM_WIFI_SSID=\"$WIFI_SSID\" -DIM_WIFI_PASS=\"$WIFI_PASS\""
21 # make clean -f "$MAKE_FILE" ESP_ROOT=$ESP_SDK_ROOT F_CPU=80000000L CHIP=esp8266 BOARD=esp8285 SKETCH="$SKETCH" $2
22 stdbuf -oL make -f "$MAKE_FILE" ESP_ROOT=$ESP_SDK_ROOT F_CPU=80000000L CHIP=esp8266 BOARD=esp8285 SKETCH="$SKETCH" $2 2>&1 | tee "$TMP"
23
24 if [ -s "$TMP" ]; then 
25         binSRC=$( cat "$TMP" | grep Linking | sed -e 's/Linking //g' )
26         cp "$binSRC" .
27
28         serialPort=$(cat "$TMP" | grep "opening port" | awk '{split($0,a," "); print a[3]}')
29 else
30         serialPort=/dev/ttyUSB0
31 fi
32
33 echo $serialPort
34
35 exit 0 
36
37
38
39
40 sleep 1
41
42 if cat "$TMP" | grep -q 'error'; then 
43         echo "exit"
44 else 
45         if [ "$1" != "noserial" ]; then
46
47                 echo "Connecting $serialPort"
48
49                 while [ 1 ]; do
50                         cat $serialPort
51                         sleep 1
52                 done
53         else 
54                 echo "Serial terminal omited"
55         fi
56 fi 
57
58 rm "$TMP"
Contact me: dev (at) shalnoff (dot) com
PGP fingerprint: A6B8 3B23 6013 F18A 0C71 198B 83D8 C64D 917A 5717